package com.example.basecore.factory;

import com.example.basecore.event.Event;
import com.example.basecore.event.EventHandler;
import lombok.NonNull;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author ycd0075
 * @date 2024-01-25 23:06
 */
public class EventHandlerFactory {

    private final Map<Class<? extends Event>, Set<EventHandler>> handlers = new HashMap();

    public EventHandlerFactory(@NonNull Map<Class<? extends Event>, Set<EventHandler>> eventHandlerMap) {
        this.handlers.putAll(eventHandlerMap);
    }

    public Set<EventHandler> create(Event event) {
        return handlers.get(event.getClass());
    }
}
